##############################
#   The Unlimited Adventure    
#   by Jerry Yang      
#   UUZ0218            
#############################
import basic
import enemy
import json

def save_file(inf,Skill,filename):
    save_inf = [inf,Skill]
    with open(filename,'w') as f_o:
        json.dump(save_inf,f_o)

def load_file(filename):
    with open(filename) as f_o:
        save_inf = json.load(f_o)
    inf = save_inf[0]
    Skill = save_inf[1]
    return(inf,Skill)

if __name__ == '__main__':
    filename = "save.json"
    try:
        [inf,Skill] = load_file(filename)
        basic.welcome_initial()
    except FileNotFoundError:
        [inf,Skill] = basic.welcome()
    while 1:
        basic.get_information(inf)
        enemy.Fight(inf,Skill)
        save_file(inf,Skill,filename)